Skip to content

feat: extract pkg/ghexpr — deduplicated GitHub Actions expression parsing package#45910

Closed
pelikhan with Copilot wants to merge 1 commit into
mainfrom
copilot/refactor-github-actions-parsing-helpers
Closed

feat: extract pkg/ghexpr — deduplicated GitHub Actions expression parsing package#45910
pelikhan with Copilot wants to merge 1 commit into
mainfrom
copilot/refactor-github-actions-parsing-helpers

Conversation

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

GitHub Actions expression parsing logic (AST nodes, tokenizer, parser, optimizer, patterns, builders) was spread across 9 files in pkg/workflow with no clear ownership boundary and several obvious pattern duplicates.

New pkg/ghexpr package

Pure expression-parsing infrastructure extracted into a standalone package with full spec documentation:

File Contents
nodes.go 10 AST node types (ConditionNode, AndNode, OrNode, NotNode, DisjunctionNode, FunctionCallNode, PropertyAccessNode, StringLiteralNode, BooleanLiteralNode, ComparisonNode)
parser.go Tokenizer, recursive-descent parser, ParseExpression, VisitExpressionTree, BreakLongExpression, StripExpressionWrapper, YAML string helpers
optimizer.go Boolean-algebra optimizer — 11 rules, fixpoint iteration, status-function safety guard
patterns.go Core regex patterns + HasExpressionMarker / ContainsExpression / IsExpression predicates
builder.go Language-level generic builders (BuildAnd, BuildOr, BuildEquals, RenderCondition, …)
doc.go Package documentation with full GitHub Actions expression grammar spec

Tests: parser_test.go, optimizer_test.go, builder_test.go, patterns_test.go, plus white-box internal tests (optimizer_white_box_test.go, parser_white_box_test.go).

pkg/workflow — backward-compatible delegation

All 38+ existing files in pkg/workflow continue to compile unchanged via Go type aliases and function var aliases:

// expression_nodes.go
type ConditionNode = ghexpr.ConditionNode
type AndNode       = ghexpr.AndNode
// …

// expression_optimizer.go
var OptimizeExpression = ghexpr.OptimizeExpression

expression_patterns.go re-exports core patterns from ghexpr and retains only gh-aw–specific context patterns (AWInputsPattern, SecretsExpressionPattern, etc.).

Duplicate patterns eliminated

File Removed Replaced with
expression_syntax_validation.go stringLiteralRegex, numberLiteralRegex ghexpr.StringLiteralPattern, ghexpr.NumberLiteralPattern
expression_safety_validation.go orExpressionPattern (identical to OrPattern) ghexpr.OrPattern
publish_assets.go githubExpressionPattern = regexp.MustCompile(...) ghexpr.IsExpression(value)

Internal white-box tests that directly accessed unexported optimizer/parser symbols are migrated to pkg/ghexpr as package ghexpr (non-_test) files.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title feat: extract pkg/ghexpr expression parsing package and fix duplicates feat: extract pkg/ghexpr — deduplicated GitHub Actions expression parsing package Jul 16, 2026
Copilot AI requested a review from pelikhan July 16, 2026 05:09
@pelikhan pelikhan closed this Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants